<template>
    <h2>登录页面</h2>
    <table class="table table-bordered"  border="1" cellpadding="0" cellspacing="0" width="250" align="center">
        <tr>
            <td>用户名</td>
            <td><input type="text" v-model="info.uname"></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input type="password" v-model="info.upwd"></td>
        </tr>
        <tr>
            <td colspan="2"><input type="button" value="登录" @click="logins"></td>
        </tr>
    </table>
   
</template>
<script setup lang="ts">
import {ref} from 'vue'
import {useuseStore} from '../../store/index.ts'
import axios from 'axios'
import { useRouter } from 'vue-router'
const router=useRouter()
const store=useuseStore()
const info=ref({
    uname:"",
    upwd:""
})


const logins=()=>{
  
    axios({
        url:"https://localhost:44394/api/UserLoginController/UsersLoginShow",
        method:"get",
        params:{
            name:info.value.uname,
            pwd:info.value.upwd
        }
    })
    .then(res=>{
        
        if(res.data.Rid==0){
            alert(res.data.Rname)
            return
        }
        if(res.data.Rid==1){
            alert(res.data.Rname)
            return
        }
        if(res.data.Rid==2){
            alert(res.data.Rname)
            store.someState=res.data.Rlist[0].Uid
            types(res.data.Rlist[0].Uid)
            
            return
        }
    })
}
const types=(id:string)=>{
    axios({
        url:"https://localhost:44394/api/UserLoginController/UserLoginInforType",
        params:{uid:id},
        method:"get",
    })
    .then(res=>{
        console.log(res.data[0].Tid)
        if(res.data[0].Tid==1){
            router.push("/userinverstshow")
        }else{
            router.push("/ginverstshow")
        }
    })
}

</script>